//
//  ViewController.m
//  03-UIPresentationController
//
//  Created by J on 15/11/8.
//  Copyright © 2015年 JZJ. All rights reserved.
//

#import "ViewController.h"
#import "JZJViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

    
    
    JZJViewController * VC=[[JZJViewController alloc]init];
    

    VC.modalPresentationStyle = UIModalPresentationPopover;//不设置就是全屏 就会直接创建UIPresentationcontroller如果设置了就会创建popoverPresentationController 来管理跳转 VC.popoverPresentationController才不会为nil
    VC.popoverPresentationController.barButtonItem=self.navigationItem.leftBarButtonItem;
    [self presentViewController:VC animated:YES completion:nil];//只要是present 就会自动创建一个 UIPresentationController  就是由presentationcontroller管理vc

    
    
    
    NSLog(@"%@ %@",VC.presentationController,VC.popoverPresentationController);//都指向管理它的 UIPresentationController
    
//    UIPresentationController *p=nil;
//    p.presentedViewController;//底下的控制器
//    p.presentingViewController;//已经推出的控制器
//    p.presentedView;//已经推出的控制器里的view
    
    
    
    //1.只要调用[self presentViewController:VC animated:YES completion:nil];
    //2.会创建一个UIPresentationController
    //3.然后由UIPresentationController 管理控制器的切换
    
    
    
}

@end
